<?php class ActivitiesController extends CmsAppController
{
	var $name = 'Activities';

	function  getRecentActivites($user_id = null)
	{
		$activites = $this->Activity->find('all',array('order'=>'created desc','limit'=>5,'conditions'=>array('user_id '=>$user_id)));
		$this->set('activites',$activites);
		
	}

	function getFollowerActivities($user_id = null)
	{
		$followingUserIds  = ClassRegistry::init('UsersFollower')->find('list',array('fields'=>array('follower_id','follower_id'),'conditions'=>array('user_id'=>$user_id)));
		if(!empty($followingUserIds))
		{
			$activites = $this->Activity->find('all',array('order'=>'created desc','limit'=>5,'conditions'=>array('user_id'=>$followingUserIds,'not'=>array('Activity.type'=>'User'))));
		}
		else
		{
			$activites =array();
		}
		$this->set('activites',$activites);
		$this->set('action','getFollowerActivities');
		$this->render('get_recent_activites');
	}
}
?>